package com.huishu.order.component;

import com.huishu.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName：RocketMqCancelOrderReciever
 * @Author: ljj
 * @Date: 2023/4/13 17:32  schedule-consumer-group
 */
@Slf4j
@Component
@RocketMQMessageListener(consumerGroup = "schedule-consumer-group", topic = "schedule-message-topic")
public class RocketMqCancelOrderReciever implements RocketMQListener<String> {

    @Autowired
    private OrderService orderService;


    @Override
    public void onMessage(String orderSn) {
        // 取消订单回滚库存
        orderService.cancelOrderRollbackStock(orderSn);
    }
}
